package kr.ne.jay.SimpleString;

public class Vector2f {
	public float x, y;

	public Vector2f() {
		x = 0;
		y = 0;
	}

	public Vector2f(Vector2f pos) {
		x = pos.x;
		y = pos.y;
	}
	
	public Vector2f(float _x, float _y) {
		x = _x;
		y = _y;
	}

	public Vector2f mul(float _mul) {
		x *= _mul;
		y *= _mul;
		return this;
	}
	
	public void set(Vector2f org) {
		x = org.x;
		y = org.y;
	}

	public Vector2f plus(Vector2f rhs) {
		return new Vector2f(x + rhs.x, y + rhs.y);
	}

	public Vector2f minus(Vector2f rhs) {
		return new Vector2f(x - rhs.x, y - rhs.y);
	}

	public Vector2f acc(Vector2f rhs) {	// operator+=
		x += rhs.x;
		y += rhs.y;
		return this;
	}
	
	public Vector2f times(float rhs) {
		return new Vector2f(x * rhs, y * rhs);
	}

	public float len() {
		return (float) Math.sqrt(len2());
	}

	public float len2() {
		return x * x + y * y;
	}

	public float dist(Vector2f rhs) {
		float diffX = (x - rhs.x);
		float diffY = (y - rhs.y);
		return (float) Math.sqrt(diffX * diffX + diffY * diffY);
	}
}
